<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ page import="com.ulic.customerManApplication.commonmodule.bo.Menu"%>
<%@ page import="com.ulic.customerManApplication.membermodule.bo.Member"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>合众人寿公益平台客户管理系统</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <style>
body,ul,ol,dl,dd,p,h1,h2,h3,h4,h5,h6,form,input,textarea,select,td,th {
	margin: 0;
	padding: 0;
	font-family: "宋体", Arial, Helvetica, sans-serif;
}

li {
	list-style: none;
}

input {
	background: none;
}

.clear {
	zoom: 1;
}

.clear:after {
	content: "";
	display: block;
	clear: both;
}
.operation{ text-align:center;}
.operation input{ 
background:none; 
border-style:none;
background:url(<%=request.getContextPath()%>/html/images/button_bg.gif) repeat-x; 
border:1px solid #999;
height:22px; 
cursor:pointer; 
text-align:center;
}

.bar {
	width: 150px;
	height: 350px;
	overflow: scroll;
	SCROLLBAR-FACE-COLOR: #9EBFE8;
	SCROLLBAR-SHADOW-COLOR: # #d9d9d9;
	SCROLLBAR-HIGHLIGHT-COLOR: # #d9d9d9;
	SCROLLBAR-3DLIGHT-COLOR: #9EBFE8;
	SCROLLBAR-DARKSHADOW-COLOR: #9EBFE8;
	SCROLLBAR-TRACK-COLOR: # #d9d9d9;
	SCROLLBAR-ARROW-COLOR: # #d9d9d9;
	float: left;
	margin-right: 30px;
	border-left: #9EBFE8 1px solid;
	border-top: #9EBFE8 1px solid;
}
</style>
		<SCRIPT type="text/javascript">
	      var GB_ROOT_DIR = "<%=request.getContextPath()%>/html/skin/";
        </SCRIPT>

		<link href="<%=request.getContextPath()%>/html/css/Main.css"
			rel="stylesheet" type="text/css" />
		<script src="<%=request.getContextPath()%>/html/jscal2/js/jscal2.js"
			charset="utf-8"></script>
		<link href="<%=request.getContextPath()%>/html/jscal2/css/jscal2.css"
			rel="stylesheet" type="text/css" />
		<link href="<%=request.getContextPath()%>/html/css/gb_styles.css"
			rel="stylesheet" type="text/css"/>
		<link href="<%= request.getContextPath() %>/html/css/tree.css"
			rel="stylesheet" type="text/css" />
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/html/js/AJS.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/html/js/AJS_fx.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/html/js/gb_scripts.js"></script>
        <script type="text/javascript"
			src="<%= request.getContextPath() %>/html/js/PopupCalendar.js"></script>
		<script type="text/javascript"
			src="<%= request.getContextPath() %>/html/js/prototype.js"></script>
		<script type="text/javascript"
			src="<%= request.getContextPath() %>/html/js/buffalo.js"></script>
		<script type="text/javascript"
			src="<%= request.getContextPath() %>/html/js/pims.js"></script>
		<script type="text/javascript"
			src="<%= request.getContextPath() %>/html/js/xtree.js"></script>
		<script type="text/javascript"
			src="<%= request.getContextPath() %>/html/js/xloadtree.js"></script>
			
			<script language="javascript" type="text/javascript">	
		  var showTree = true;	
	/*--------------------------------------------------------------
		功能：初始化 载入根部门和用户
	---------------------------------------------------------------*/
	function Init()
	{    	
		//然后载入Left，树
		TreeMenu();
	}
	/*-------------------------------------------------------------
		功能：Tree Menu
	--------------------------------------------------------------*/
	function TreeMenu()
	{
		/// XP Look
		webFXTreeConfig.rootIcon		= "html/images/tree/list_fun1.gif";
		webFXTreeConfig.openRootIcon	= "html/images/tree/list_fun1.gif";
		webFXTreeConfig.folderIcon		= "html/images/tree/folder.gif";
		webFXTreeConfig.openFolderIcon	= "html/images/tree/folderopen.gif";
		webFXTreeConfig.fileIcon		= "html/images/tree/file.gif";
		webFXTreeConfig.lMinusIcon		= "html/images/tree/Lminus.png";
		webFXTreeConfig.lPlusIcon		= "html/images/tree/Lplus.png";
		webFXTreeConfig.tMinusIcon		= "html/images/tree/Tminus.png";
		webFXTreeConfig.tPlusIcon		= "html/images/tree/Tplus.png";
		webFXTreeConfig.iIcon			= "html/images/tree/I.png";
		webFXTreeConfig.lIcon			= "html/images/tree/L.png";
		webFXTreeConfig.tIcon			= "html/images/tree/T.png";
	
		var tree = new WebFXTree("会员群组");
		<% 
		String[] memberType = {"绿卡会员","银卡会员","金卡会员","金箔卡会员","钻石卡会员"}; 
	    List<Member> memberlist = (List<Member>)request.getAttribute("members"); 
		for(int i=0;i<memberType.length;i++)
		{
		%>
			var type = '&nbsp;<%=memberType[i]%>';
			var typename = '<%=memberType[i]%>';
			var a = new WebFXTreeItem(""+type+"","javascript:chose(0,'"+typename+"');");
			<%
				Iterator<Member> iter = memberlist.iterator();
				while(iter.hasNext())
				{
					Member member = iter.next();
					if(member.getMemberType().equals(memberType[i])){
				%>
					var memberName = '&nbsp;&nbsp;<%=member.getMemberName()%>';
					var memberNameChosen = '<%=member.getMemberName()%>';
					var memberIdChosen = '<%=member.getId()%>';
					var b = new WebFXTreeItem(""+memberName+"","javascript:chose("+memberIdChosen+",'"+memberNameChosen+"');");
					a.add(b);	
				<%}}%>
			tree.add(a);
		<%}%>
		document.getElementById("tree").innerHTML = tree;	
	}
     
     
     var name = "";
     var nameNum = 0;
     var removeDiv;
     var mid;
     function chose(memberId,memberName){
        mid = memberId;
     	name = memberName;
     }
     function add(){
       if(name == "绿卡会员"){
        <%
               Iterator<Member> iter = memberlist.iterator();
				while(iter.hasNext())
				{
					Member member = iter.next();
					if(member.getMemberType().equals("绿卡会员")){
        			
        %>
       var greenMember = '<%=member.getMemberName()%>';
       var id = '<%=member.getId()%>';
       if(isChosen(id,greenMember)){
       nameNum = nameNum+1;
       document.getElementById("chosen").innerHTML= document.getElementById("chosen").innerHTML+"<div name='memberName' onclick='choseRemove(this)' style='border:1px solid #9EBFE8;'><input type='text' name='receive' readonly='readonly' style='border:none;cursor:pointer;' value= '"+greenMember+"' /><input type='hidden' name='receiveId' style='border:none;' value= '"+id+"' /></div>";
       }
       <%
         }}
       %>
       }else if(name == "银卡会员"){
        <%
                Iterator<Member> iter2 = memberlist.iterator();
				while(iter2.hasNext())
				{
					Member member = iter2.next();
					if(member.getMemberType().equals("银卡会员")){
        			
        %>
       var silverMember = '<%=member.getMemberName()%>';
       var id = '<%=member.getId()%>';
        if(isChosen(id,silverMember)){
       nameNum = nameNum+1;
       document.getElementById("chosen").innerHTML= document.getElementById("chosen").innerHTML+"<div name='memberName' onclick='choseRemove(this)' style='border:1px solid #9EBFE8;'><input type='text' name='receive' readonly='readonly' style='border:none;cursor:pointer;' value= '"+silverMember+"' /><input type='hidden' name='receiveId' style='border:none;' value= '"+id+"' /></div>";
       }
       <%
         }}
       %>
       }else if(name == "金卡会员"){
        <%
              Iterator<Member> iter3 = memberlist.iterator();
				while(iter3.hasNext())
				{
					Member member = iter3.next();
					if(member.getMemberType().equals("金卡会员")){
        			
        %>
       var goldenMember = '<%=member.getMemberName()%>';
       var id = '<%=member.getId()%>';
       if(isChosen(id,goldenMember)){
       nameNum = nameNum+1;
       document.getElementById("chosen").innerHTML= document.getElementById("chosen").innerHTML+"<div name='memberName' onclick='choseRemove(this)' style='border:1px solid #9EBFE8;'><input type='text' name='receive' readonly='readonly' style='border:none;cursor:pointer;' value= '"+goldenMember+"' /><input type='hidden' name='receiveId' style='border:none;' value= '"+id+"' /></div>";
       }
       <%
         }}
       %>
       }else if(name == "金箔卡会员"){
        <%
               Iterator<Member> iter4 = memberlist.iterator();
				while(iter4.hasNext())
				{
					Member member = iter4.next();
					if(member.getMemberType().equals("金箔卡会员")){
        			
        %>
       var PMember = '<%=member.getMemberName()%>';
       var id = '<%=member.getId()%>';
        if(isChosen(id,PMember)){
       nameNum = nameNum+1;
       document.getElementById("chosen").innerHTML= document.getElementById("chosen").innerHTML+"<div name='memberName' onclick='choseRemove(this)' style='border:1px solid #9EBFE8;'><input type='text' name='receive' readonly='readonly' style='border:none;cursor:pointer;' value= '"+PMember+"' /><input type='hidden' name='receiveId' style='border:none;' value= '"+id+"' /></div>";
       }
       <%
         }}
       %>
       }else if(name == "钻石卡会员"){
        <%
                Iterator<Member> iter5 = memberlist.iterator();
				while(iter5.hasNext())
				{
					Member member = iter5.next();
					if(member.getMemberType().equals("钻石卡会员")){
        			
        %>
       var diamonMember = '<%=member.getMemberName()%>';
        var id = '<%=member.getId()%>';
       if(isChosen(id,diamonMember)){
       nameNum = nameNum+1;
       document.getElementById("chosen").innerHTML= document.getElementById("chosen").innerHTML+"<div name='memberName' onclick='choseRemove(this)' style='border:1px solid #9EBFE8;'><input type='text' name='receive' readonly='readonly' style='border:none;cursor:pointer;' value= '"+diamonMember+"' /><input type='hidden' name='receiveId' style='border:none;' value= '"+id+"' /></div>";
       }
       <%
         }}
       %>
       }else{
	       if(isChosen(mid,name)){
	       nameNum = nameNum+1;
	       document.getElementById("chosen").innerHTML= document.getElementById("chosen").innerHTML+"<div name='memberName' onclick='choseRemove(this)' style='border:1px solid #9EBFE8;'><input type='text' name='receive' readonly='readonly' style='border:none;cursor:pointer;' value= '"+name+"' /><input type='hidden' name='receiveId' style='border:none;' value= '"+mid+"' /></div>";
	       
	       }
	       name=null;
	       mid=0;
       }
     }
     
     function choseRemove(obj){
         if(removeDiv != null){
        	 removeDiv.style.background='#FFFFFF';
         }
         removeDiv = obj
         removeDiv.style.background='#9EBFE8';
     }
     
     function remove(){
      if(removeDiv != null && removeDiv.length != 0){
      removeDiv.innerHTML="";
      removeDiv.style.display="none";
      }
     }
     
       
     function addAll(){ 
       
     	<%
               Iterator<Member> iter6 = memberlist.iterator();
				while(iter6.hasNext())
				{
					Member member = iter6.next();
        %>
       var allmember = '<%=member.getMemberName()%>';
       var id = '<%=member.getId()%>';
       if(isChosen(id,allmember)){
       nameNum = nameNum+1;
       document.getElementById("chosen").innerHTML= document.getElementById("chosen").innerHTML+"<div name='memberName' onclick='choseRemove(this)' style='border:1px solid #9EBFE8;'><input type='text' name='receive' style='border:none;cursor:pointer;' readonly='readonly' value= '"+allmember+"' /><input type='hidden' name='receiveId' style='border:none;' value= '"+id+"' /></div>";
       }
       <%
        }
       %>
     }
     
     function removeAll(){
	     document.getElementById("chosen").innerHTML="";
     }
     
     function isChosen(idChosenId,isChosenName){ 
        var preceiveIds = parent.parent.document.getElementById("copyToId");
        var preceiveIdStr;
        if(preceiveIds != null && preceiveIds.value.length != 0){
         preceiveIdStr = preceiveIds.value.split(";");
         for(var i=0;i<preceiveIdStr.length;i++){
         	if(parseInt(idChosenId) == parseInt(preceiveIdStr[i])){
		        	      alert(isChosenName+"会员已选");
		        	      return false;
		    }
         } 
        }
        var receiveIds = document.getElementsByName("receiveId");
        if(isChosenName !=null && isChosenName.length!=0){
	        if(receiveIds.length>0){
		        for(var i=0;i<receiveIds.length;i++){
		        	  if(parseInt(idChosenId) == parseInt(receiveIds[i].value)){
		        	      alert(isChosenName+"会员已选");
		        	      return false;
		        	  }
		        }
	        }
	        return true;
        }else{
          return false;
        }
     }
     
     
     function subok(){
       var receiveIds = document.getElementsByName("receiveId");
       var receiveNames = document.getElementsByName("receive");
       var receive = "";
       var receiveId ="";
       for(var i=0;i<receiveIds.length;i++){
       	  receive = receive+receiveNames[i].value+";";
       	  receiveId = receiveId + receiveIds[i].value+";";
       }
       if(receive.length != 0){
	       if(parent.parent.document.getElementById("copyTo").value.length != 0){
	   	    parent.parent.document.getElementById("copyTo").value = parent.parent.document.getElementById("copyTo").value+receive ;
	   	    parent.parent.document.getElementById("copyToId").value=  parent.parent.document.getElementById("copyToId").value+receiveId;
	       }else{
	   	    parent.parent.document.getElementById("copyTo").value =receive ;
	   	    parent.parent.document.getElementById("copyToId").value=receiveId;
	       }
       }
   	   parent.parent.GB_CURRENT.hide();
     }
     
		</script>

			
  </head>
  
  <body onload="javascript:Init();">
       <div class="container">
			<div class="wrap clear">
				<div class="sub_wp_right">
					<div class="rt_tt">
						<h3 class="tittle">
							选择抄送人
						</h3>
					</div>
					<div class="ct"  style="height:430px;">
							<div style="margin-top: 30px; margin-left: 100px; float: center">

								<div class="bar">
									<div id="tree"></div>
								</div>
								<div style="float: left; margin-right: 30px;" class="operation">
									<br />
									<br />
									<br />
									<input type="button" value="全部添加>>" onclick="addAll()"
										style="width: 100px;" />
									<br /><br>
									<input type="button" value="添  加>>" onclick="add()"
										style="width: 100px;" />
									<br/>
									<br><br>
									<input type="button" value="<<移 出" onclick="remove()"
										style="width: 100px;" />
									<br><br/>
									<input type="button" value="<<全部移出" onclick="removeAll()"
										style="width: 100px;" />
								</div>
								<div class="bar" id="chosen">

								</div>
							</div>
							
					</div>
						<div style="float: center" class="btn" >
							<input type="button" value="确定" onclick="subok()" />
						</div>
				</div>
			</div>
		</div>
  </body>
</html>
